<?php
class Process {
	/**************************************************/
	/******************** MEMBER **********************/
	/**************************************************/
	private $name;		
	private $runtime;	//CPU-Laufzeit
	private $arrive;	//Ankunftszeit
	private $priority;	//Prioritaet
	private $remainingRuntime; //Verbleibende Laufzeit
	private $startTime; //Startzeit des Processes
	private $endTime; //Zeitpunkt andem der Process geendet hat

	/**************************************************/
	/***************** KONSTRUTOREN *******************/
	/**************************************************/
	/*Standart Konstruktor*/
	public function __construct($name, $runtime, $arrive, $priority, $remainingRuntime){
			$this->name = $name;
			$this->runtime = $runtime+0;
			$this->arrive = $arrive+0;
			$this->priority = $priority+0;
			$this->remainingRuntime = $remainingRuntime+0;
	}
	
	/**************************************************/
	/************* PUBLIC METHODEN ********************/
	/**************************************************/
	/*Gibt den Namen des Processe zurueck*/
	public function getName (){
		return $this->name;
	}
	
	/*Gibt die CPU-Laufzeit des Processe zurueck*/
	public function getRuntime (){
		return $this->runtime;
	}
	
	/*Gibt die Ankunfszeit des Processe zurueck*/
	public function getArrive (){
		return $this->arrive;
	}
	
	/*Gibt die Prioritaet des Processe zurueck*/
	public function getPriority (){
		return $this->priority;
	}
	
	/*Gibt die Restliche Laufzeit des Processe zurueck des Processe zurueck*/
	public function getRemainingRuntime (){
		return $this->remainingRuntime;
	}
	
	/*Gibt den Nmen des Processe zurueck*/
	public function setRemainingRuntime ($remainingRuntime){
		if ($remainingRuntime < $this->remainingRuntime && $this->remainingRuntime != 0){
			$this->remainingRuntime = $remainingRuntime;
		}else {
			$this->remainingRuntime = 0;
		}
	}
	
	/*Gbit den Zeitpunt in ms Zurueck wann der Process gestartet wurde*/
	public function getStartTime(){
		return $this->startTime;
	}
	
	/*Setzt den Startzeitpunkt des Processes*/
	public function setEndTime($value){
		$this->endTime = $value;	
	}
	
		/*Gbit den Zeitpunt in ms Zurueck wann der Process gestartet wurde*/
	public function getEndTime(){
		return $this->endTime;
	}
	
	/*Setzt den Startzeitpunkt des Processes*/
	public function setStartTime($value){
		$this->startTime = $value;	
	}
	
	/*Clont das Process Object*/
	public function __clone (){
		return unserialize(serialize($this)); 	
	}
	
	public function equals ($process){
		$equals = true;
		if ($this->name != $process->getName()){
			$equals = false;
		}
		if ($this->arrive != $process->getArrive()){
			$equals = false;
		}
		if($this->priority != $process->getPriority()){
			$equals = false;
		}
		if ($this->runtime != $process->getRuntime()){
			$equals = false;	
		}
		if ($this->remainingRuntime != $process->getRemainingRuntime()){
			$equals = false;	
		}
		return $equals;
	}
}
?>